package unittest
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	
	import shooting.ui.MissileContainer;
	import shooting.ui.layer.BitmapLayer;
	import shooting.ui.missile.IMissile;
	import shooting.ui.missile.MissaleBase;
	
	import utils.Library;

	public class UnitTest_BtimapLayer extends Sprite
	{
		[Embed(source='../assets/res.swf', mimeType='application/octet-stream')]
		private var CRes:Class;
		
		private var m_lib:Library;
		private var myLayer:BitmapLayer;
		private var msContainer:MissileContainer;
		private var readyCount:Number = 0;
		
		public function UnitTest_BtimapLayer()
		{
			super();
			m_lib = new Library(new CRes(),onInit);
		}
		private function onInit():void
		{
			msContainer = new MissileContainer();
			msContainer.setArea(0,0,800,600);
			var i:uint;
			var leng:uint = 1000;
			var ms:IMissile;
			for( i = 0; i < leng; i++)
			{
				ms = new MissaleBase("smallBlue",new Point(500,300),.4+i*.01,i);
				msContainer.addMissile(ms);
				ms = new MissaleBase("redmissile",new Point(500,300),.3+i*.03,i);
				msContainer.addMissile(ms);
			}
			myLayer = new BitmapLayer(m_lib);
			myLayer.initLayer(800,600);
			myLayer.setContainer(msContainer);
			
			this.addChild(myLayer);
			addEvents();
		}
		private function addEvents():void
		{
			this.addEventListener( Event.ENTER_FRAME, layerRendering);
		}
		private function layerRendering(e:Event):void
		{
			
			if(readyCount>100 || readyCount ==0)
			{
				msContainer.render();
			}
			
			myLayer.render();
			readyCount++;
		}
	}
}